package com.easy.controller;

import com.easy.bean.Notion;
import com.easy.service.NotionService;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("notion")
public class NotionController {

    @Autowired
    NotionService notionService;

    @PostMapping
    public Result add(@RequestBody Notion notion){
        Object obj=notionService.add(notion);
        return Result.success(obj);
    }

    @PutMapping
    public Result edit(@RequestBody Notion notion){
        Object obj=notionService.edit(notion);
        return Result.success(obj);
    }

    @DeleteMapping("{id}")
    public Result del(@PathVariable("id") Integer id){
        Object obj=notionService.del(id);
        return Result.success(obj);
    }

    @GetMapping("{id}")
    public Result one(@PathVariable("id") Integer id){
        Object obj=notionService.one(id);
        return Result.success(obj);
    }

    @GetMapping("all")
    public Result all(Notion notion){
        Object obj=notionService.all(notion);
        return Result.success(obj);
    }

    @GetMapping("page")
    public Result page(com.easy.util.Page page,Notion notion){
        notionService.page(page,notion);
        return Result.success(page);
    }
}
